import logging
from   redis import  StrictRedis


class Config(object):
    """工程配置信息"""
    DEBUG = True

    SECRET_KEY = "SDADASFSADDAS"

    # 数据库的配置信息
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/wwe"
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    # 在请求结束的时候,如果指定此配置为True,那么SQLALchemy  会自动执行一次 db.session.commit操作
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True

    # redis配置
    REDIS_HOST = "127.0.0.1"
    REDIS_PORT = 6379


    # session 保存配置
    SESSION_TYPE = 'redis'
    # 开启session 签名
    SESSION_USE_SIGNER = True
    # 指定 session 保存的 redis
    SESSION_REDIS = StrictRedis(host=REDIS_HOST,port=REDIS_PORT)
    # 设置需要过期
    SESSION_PERMANET = False
    # 设置 过期时间
    PERMANET_SESSION_LIFETIME = 86400 * 2


    # 设置日志等级
    LOGIN_LEVEL = logging.DEBUG


class DevelopmentConfig(Config):
    """开发环境下的的配置"""
    DEBUG = True
    LOG_LEVEL = logging.DEBUG

class  ProductionConfig(Config):
    """生产环境"""
    DEBUG =  False
    LOG_LEVEL = logging.WARNING

class TestingConfig(Config):
    """单元测试环境下的配置"""
    DEBUG = True
    TESTING = True

config = {
    "development" : DevelopmentConfig,
    "production" : ProductionConfig,
    "testing": TestingConfig
}
